package main

import (
	"cow_golang/gate_server/internal/handle"
	"cow_golang/shared_mod/tcplib"
	"cow_golang/shared_mod/tcplib/iface"
	"fmt"
)

func OnCreateConn(session iface.ISession) {
	fmt.Println("OnCreateConn is call")
}

func OnCloseConn(session iface.ISession) {
	fmt.Println("OnCloseConn is call")
}

func main() {
	s := tcplib.NewServer("Gate Server", "127.0.0.1", 8888, "tcp4")
	// 设置服务的coder 编解码器

	//设置服务器hook
	s.SetCreateConnHook(OnCreateConn)
	s.SetCloseConnHook(OnCloseConn)
	//加入处理协议和对应的方法
	s.AddHandle(0, &handle.HelloHandle{})
	s.AddHandle(1, &handle.PingHandle{})

	s.Serve()
}
